<?php
    include 'class/mysql.php';

    function userLogged($id)
    {
        $result = $db->get_row("Select username from Users WHERE id='".$id."'");
        return $result;
    }

    function login($username,$password)
    {
        $result = $db->get_row("Select * from Users WHERE username = '".$username."' && password ='".$password."'");

        if($result != null)
        {
            $_SESSION['id'] = $result->id;
            $_SESSION['admin'] = $result->admin;
            $_SESSION['name'] = $result->username;
            header("Location:index.php");
        }
        else
        {
            echo "Login Failed";
        }
    }

